home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / RTANKSRC.ZIP / RADIO.C < prev    next >
Text File  |  1989-02-26  |  3KB  |  103 lines

  1. /*
  2.  * RADIO.C - Radio communications manager module
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <dtypes.h>
  8.  
  9. #include "tiles.h"
  10.  
  11. #include "host.h"
  12. #include "newload.h"
  13. #include "callasm.h"
  14.  
  15. /*<f>----------------------------------------
  16.  * FUNCTION: <s> void clear_channel(p_CHANNEL c)
  17.  * PURPOSE : Clear all messages on a channel
  18.  *         :
  19.  * CREATION: 02/10/1989 09:29:46
  20.  */
  21. void clear_channel(p_CHANNEL c)
  22. {
  23.    c->head=c->tail=0;
  24. } /* void clear_channel(p_CHANNEL c) */
  25.  
  26. /*<f>----------------------------------------
  27.  * FUNCTION: <s> void add_message_to_channel(p_CHANNEL c, int n1, int n2, int n3)
  28.  * PURPOSE : Append message n1,n2,n3 to channel C
  29.  *         :
  30.  * CREATION: 02/10/1989 09:37:28
  31.  */
  32. void add_message_to_channel(p_CHANNEL c, int n1, int n2, int n3)
  33. {
  34.    if (peek_ahead(c->head)==c->tail)
  35.       return;
  36.  
  37.    c->message[c->head].note1=n1;
  38.    c->message[c->head].note2=n2;
  39.    c->message[c->head].note3=n3;
  40.  
  41.    inc_pointer(&c->head);
  42.  
  43. } /* void add_message_to_channel(p_CHANNEL c, int n1, int n2, int n3) */
  44.  
  45. /*<f>----------------------------------------
  46.  * FUNCTION: <s> int peek_ahead(int p)
  47.  * PURPOSE : What would the next pointer increment normally be?
  48.  *         :
  49.  * CREATION: 02/10/1989 09:45:38
  50.  */
  51. int peek_ahead(int p)
  52. {
  53.    p++; if (p>=MAX_MESSAGES) p=0;
  54.    return p;
  55. } /* int peek_ahead(int p) */
  56.  
  57. /*<f>----------------------------------------
  58.  * FUNCTION: <s> void inc_pointer(int *p)
  59.  * PURPOSE : Increment queue head or tail pointer to next position
  60.  *         :
  61.  * CREATION: 02/10/1989 09:46:39
  62.  */
  63. void inc_pointer(int *p)
  64. {
  65.  
  66.    (*p)++; if ((*p) >= MAX_MESSAGES) (*p)=0;
  67.  
  68. } /* void inc_pointer(int *p) */
  69.  
  70. /*<f>----------------------------------------
  71.  * FUNCTION: <s> void read_message(p_CHANNEL c, int *n1, int *n2, int *n3)
  72.  * PURPOSE : Read message from channel C and place results
  73.  *         : in n1, n2, and n3
  74.  * CREATION: 02/10/1989 10:06:01
  75.  */
  76. void read_message(p_CHANNEL c, int *n1, int *n2, int *n3)
  77. {
  78.    (*n1)=0;
  79.    (*n2)=0;
  80.    (*n3)=0;
  81.  
  82.    if (c->head==c->tail)
  83.       return;
  84.  
  85.    (*n1)=c->message[c->tail].note1;
  86.    (*n2)=c->message[c->tail].note2;
  87.    (*n3)=c->message[c->tail].note3;
  88.  
  89.    inc_pointer(&c->tail);
  90.  
  91. } /* void read_message(p_CHANNEL c, int *n1, int *n2, int *n3) */
  92.  
  93. /*<f>----------------------------------------
  94.  * FUNCTION: <s> BOOL any_messages(p_CHANNEL c)
  95.  * PURPOSE : TRUE if any messages in queue, FALSE otherwise
  96.  *         :
  97.  * CREATION: 02/10/1989 10:36:35
  98.  */
  99. BOOL any_messages(p_CHANNEL c)
  100. {
  101.    return( (c->head==c->tail) ? FALSE : TRUE);
  102. } /* BOOL any_messages(p_CHANNEL c) */
  103.